#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int convert( char ch )
{
    if ( ch == 'E' || ch == 'C' ) return 0;
    if ( ch == 'W' || ch == 'B' ) return 1;
    if ( ch == 'S' || ch == 'L' ) return 2;
    if ( ch == 'N' || ch == 'R' ) return 3;
}

char nextStep( char ch, char lastStep )
{
    if ( ch == 'E' || ch == 'W' || ch == 'S' || ch == 'N' )
        return ch;
    
    static const char arr[][ 4 ] = {    'E', 'W', 'S', 'N',
                                        'W', 'E', 'N', 'S',
                                        'N', 'S', 'E', 'W',
                                        'S', 'N', 'W', 'E'  };

    return arr[ convert( ch ) ][ convert( lastStep ) ];
}

class Point2D
{
private :
    int absc;
    int ordi;
public :
    Point2D( int abscissa = 0, int ordinate = 0 )
        : absc( abscissa ), ordi( ordinate )
    {   }

    void move( char side )
    {
        static const int OX[] = { 1, -1, 0, 0 };
        static const int OY[] = { 0, 0, -1, 1 };

        absc += OX[ convert( side ) ];
        ordi += OY[ convert( side ) ];
    }

    friend ostream& operator<< ( ostream& os, const Point2D &p )
    {
        os << "( " << setw(3) << p.absc << ", " << setw(3) << p.ordi << " )";
        return os;
    }
};

int main()
{
    string str = "WRECSSCRWWCRN";
    int len = str.length();

    for( int i = 1; i < len; i++ )
        str[ i ] = nextStep( str[ i ], str[ i - 1 ] );

    Point2D ship( 0, 0 );

    cout << "Start : " << ship << endl;

    for( int i = 0; i < len; i++ )
    {
        ship.move( str[ i ] );
        cout << str[ i ] << " -> " << ship << endl;
    }

    return 0;
